﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="NemoKachi.MainPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:NemoKachi"
    xmlns:localelm="using:NemoKachi.CustomElements"
    xmlns:common="using:NemoKachi.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>

        <Grid Grid.Row="1">
            <GridView HorizontalAlignment="Left" Width="853" Height="116" ItemsSource="{Binding TokenCollection}" DataContext="{StaticResource AccountCollector}"/>
            <localelm:TweetInput x:Name="tweetInput" Width="600" Height="300" />
            <localelm:TimelineColumn Width="300" Height="600" DataContext="{StaticResource tempColumn}" Margin="14" HorizontalAlignment="Left" />
            
            <StackPanel Margin="0,0,23,6" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="StartStream" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="UserStreamTemporary" />
                </Grid>
                
                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="GetCard" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="cardBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="GetCardTemporary" />
                </Grid>

                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="Username" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="usernameBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="UsersShowTemporary" />
                </Grid>

                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="Show" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="idBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="IdLoad" />
                </Grid>

                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="Reply" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="replyIdBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="RegisterReplyIdTemporary" />
                </Grid>

                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="Retweet" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="retweetIdBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="RetweetTemporary" />
                </Grid>

                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="Destroy" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="destroyIdBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="DestroyTemporary" />
                </Grid>

                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="Favorite" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="favoriteIdBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="FavoriteTemporary" />
                </Grid>
                
                <Grid Width="270" Height="32" Margin="3">
                    <TextBlock Text="Unfavorite" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,160,0" />
                    <TextBox x:Name="unfavoriteIdBox" Margin="120,0,40,0" />
                    <Button HorizontalAlignment="Right" Width="40" VerticalAlignment="Stretch" Click="FavoriteDestroyTemporary" />
                </Grid>
            </StackPanel>
        </Grid>
        
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
